# Maintainer: Mark Wagie <mark dot wagie at tutanota dot com>
# Co-Maintainer: George Rawlinson <george@rawlinson.net.nz>
# Contributor: Phillip Smith <pkgbuild@phs.id.au>
# Contributor: Nathan Owe <ndowens04 at gmail>

pkgname=freeipmi
pkgver=1.6.10
pkgrel=1
pkgdesc='IPMI remote console and system management software'
arch=('loong64' 'x86_64')
url='https://www.gnu.org/software/freeipmi'
license=('GPL')
depends=('libgcrypt')
optdepends=('perl: for contrib scripts')
backup=(
  "etc/$pkgname/$pkgname.conf"
  "etc/$pkgname/${pkgname}_interpret_sel.conf"
  "etc/$pkgname/${pkgname}_interpret_sensor.conf"
  "etc/$pkgname/ipmidetect.conf"
  "etc/$pkgname/ipmidetectd.conf"
  "etc/$pkgname/ipmiseld.conf"
  "etc/$pkgname/libipmiconsole.conf"
)
options=('!libtool')
source=(
  "https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz"{,.sig}
  'tmpfiles.conf'
)
sha512sums=('90b6b78cdd119c2a1f332f007333aa6df70c6e3de0fd81ab007025392ee7cb7a01ab4a7a174d1f2e760c55d78f21ebbbe9667af661ccdd669e4b54edb1346937'
            'SKIP'
            '3516d972d0b078e2cdedc1362f98bd061fbee583c7ac97c1c728baf2dbe41b62847dbe04e0381422d70c55101240176443ce15e422dbc6d6a583321bb0d39b22')
b2sums=('e217570d8fcf78ca9d04aad4d5bd46b4120beb21f2dcfb083bc9779a4541856e08ec6e87549651ee3c9b62fe54521585e192c784254dd9482bf9da09935853ae'
        'SKIP'
        '5354e0b716b0806ac6f82dbbae533cb86f302d1952b948df6b5ab5bd41bf194ec927c9c39fd4d5969c2f4de8cfdbf3b66a4a1c1faaee4e5768201eaef83ca991')
validpgpkeys=('A865A9FB6F0387624468543A3EFB7C4BE8303927') # Albert Chu <chu11@llnl.gov>

prepare() {
  cd "$pkgname-$pkgver"

  autoreconf -vi

  ./configure \
    --prefix=/usr \
    --exec-prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --mandir=/usr/share/man \
    --sbindir=/usr/bin \
    --disable-init-scripts \
    --with-systemdsystemunitdir=/usr/lib/systemd/system \
    --with-systemconfigdir=/etc/conf.d
}

build() {
  cd "$pkgname-$pkgver"

  make
}

package() {
  cd "$pkgname-$pkgver"
  make DESTDIR="$pkgdir" install

  # systemd-tmpfiles integration
  install -Dm644 "$srcdir/tmpfiles.conf" "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"

  # delete cache
  rm -rf "$pkgdir/var/cache"
}
